home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / lynx-2.4 / WWW / Library / Implementation / HTStyle.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-28  |  6.6 KB  |  184 lines

  1. /*                                                       HTStyle: Style management for libwww
  2.                               STYLE DEFINITION FOR HYPERTEXT
  3.                                              
  4.    Styles allow the translation between a logical property of a piece of text and its
  5.    physical representation.
  6.    
  7.    A StyleSheet is a collection of styles, defining the translation necessary to represent
  8.    a document. It is a linked list of styles.
  9.    
  10. Overriding this module
  11.  
  12.    Why is the style structure declared in the HTStyle.h module, instead of having the user
  13.    browser define the structure, and the HTStyle routines just use sizeof() for copying?
  14.    
  15.    It's not obvious whether HTStyle.c should be common code.  It's useful to have common
  16.    code for loading style sheets, especially if the movement toward standard style sheets
  17.    gets going.
  18.    
  19.    If it IS common code, then both the hypertext object and HTStyle.c must know the
  20.    structure of a style, so HTStyle.h is a suitable place to put that.  HTStyle.c has to
  21.    be compiled with a knowledge of the
  22.    
  23.    It we take it out of the library, then of course HTStyle could be declared as an
  24.    undefined structure. The only references to it are in the structure-flattening code
  25.    HTML.c and HTPlain.c, which only use HTStypeNamed().
  26.    
  27.    You can in any case override this function in your own code, which will prevent the
  28.    HTStyle from being loaded.  You will be able to redefine your style structure in this
  29.    case without problems, as no other moule needs to know it.
  30.    
  31.  */
  32. #ifndef HTStyle_H
  33. #define HTStyle_H
  34.  
  35. #ifndef HTUTILS_H
  36. #include "HTUtils.h"
  37. #endif /* HTUTILS_H */
  38. #include "HTAnchor.h"
  39.  
  40. typedef long int HTFont;        /* Dummy definition instead */
  41.  
  42. #ifdef SHORT_NAMES
  43. #define HTStyleNew                      HTStNew
  44. #define HTStyleFree                     HTStFree
  45. #define HTStyleRead                     HTStRead
  46. #define HTStyleWrite                    HTStWrite
  47. #define HTStyleSheetNew                 HTStShNe
  48. #define HTStyleSheetFree                HTStShFr
  49. #define HTStyleNamed                    HTStName
  50. #define HTStyleForParagraph             HTStFoPa
  51. #define HTStyleMatching                 HTStMatc
  52. #define HTStyleForRun                   HTStFoRu
  53. #define HTStyleSheetAddStyle            HTStShAd
  54. #define HTStyleSheetRemoveStyle         HTStShRm
  55. #define HTStyleSheetRead                HTStShRe
  56. #define HTStyleSheetWrite               HTStShWr
  57. #endif
  58.  
  59. #ifdef NeXT_suppressed
  60. #include <appkit/appkit.h>
  61. typedef NXCoord HTCoord;
  62. #define HTParagraphStyle NXTextStyle
  63. #define HTCoord NXCoord
  64. typedef struct _color {
  65.         float   grey;
  66.         int     RGBColor;
  67. } HTColor;
  68. #else
  69.  
  70. typedef float HTCoord;
  71.  
  72. typedef struct _HTParagraphStyle {
  73.     HTCoord     left_indent;            /* @@@@ junk! etc etc*/
  74. } HTParagraphStyle;
  75.  
  76. typedef int HTColor;            /* Sorry about the US spelling! */
  77.  
  78. #endif
  79.  
  80.  
  81.  
  82. #define STYLE_NAME_LENGTH       80      /* @@@@@@@@@@@ */
  83.         
  84. typedef struct {
  85.     short               kind;           /* only NX_LEFTTAB implemented*/
  86.     HTCoord             position;       /* x coordinate for stop */
  87. } HTTabStop;
  88.  
  89.  
  90. /*      The Style Structure
  91. **      -------------------
  92. */
  93.  
  94. typedef struct _HTStyle {
  95.  
  96. /*      Style management information
  97. */
  98.     struct _HTStyle     *next;          /* Link for putting into stylesheet */
  99.     char *              name;           /* Style name */
  100.     char *              SGMLTag;        /* Tag name to start */
  101.  
  102.  
  103. /*      Character attributes    (a la NXRun)
  104. */
  105.     HTFont              font;           /* Font id */
  106.     HTCoord             fontSize;       /* The size of font, not independent */
  107.     HTColor             color;  /* text gray of current run */
  108.     int                 superscript;    /* superscript (-sub) in points */
  109.  
  110.     HTAnchor            *anchor;        /* Anchor id if any, else zero */
  111.  
  112. /*      Paragraph Attribtes     (a la NXTextStyle)
  113. */
  114.     HTCoord             indent1st;      /* how far first line in paragraph is
  115.                                  * indented */
  116.     HTCoord             leftIndent;     /* how far second line is indented */
  117.     HTCoord             rightIndent;    /* (Missing from NeXT version */
  118.     short               alignment;      /* quad justification */
  119.     HTCoord             lineHt;         /* line height */
  120.     HTCoord             descentLine;    /* descender bottom from baseline */
  121.     HTTabStop           *tabs;          /* array of tab stops, 0 terminated */
  122.  
  123.     BOOL                wordWrap;       /* Yes means wrap at space not char */
  124.     BOOL                freeFormat;     /* Yes means \n is just white space */
  125.     HTCoord             spaceBefore;    /* Omissions from NXTextStyle */
  126.     HTCoord             spaceAfter;
  127.     int                 paraFlags;      /* Paragraph flags, bits as follows: */
  128.  
  129. #define PARA_KEEP       1       /* Do not break page within this paragraph */
  130. #define PARA_WITH_NEXT  2       /* Do not break page after this paragraph */
  131.  
  132. #define HT_JUSTIFY 0            /* For alignment */
  133. #define HT_LEFT 1
  134. #define HT_RIGHT 2
  135. #define HT_CENTER 3
  136.  
  137. } HTStyle;
  138.  
  139.  
  140. /*      Style functions:
  141. */
  142. extern HTStyle * HTStyleNew NOPARAMS;
  143. extern HTStyle* HTStyleNewNamed PARAMS ((CONST char * name));
  144. extern HTStyle * HTStyleFree PARAMS((HTStyle * self));
  145. #ifdef SUPRESS
  146. extern HTStyle * HTStyleRead PARAMS((HTStyle * self, HTStream * stream));
  147. extern HTStyle * HTStyleWrite PARAMS((HTStyle * self, HTStream * stream));
  148. #endif
  149. /*              Style Sheet
  150. **              -----------
  151. */
  152. typedef struct _HTStyleSheet {
  153.         char *          name;
  154.         HTStyle *       styles;
  155. } HTStyleSheet;
  156.  
  157.  
  158. /*      Stylesheet functions:
  159. */
  160. extern HTStyleSheet * HTStyleSheetNew NOPARAMS;
  161. extern HTStyleSheet * HTStyleSheetFree PARAMS((HTStyleSheet * self));
  162. extern HTStyle * HTStyleNamed PARAMS((HTStyleSheet * self, CONST char * name));
  163. extern HTStyle * HTStyleForParagraph PARAMS((HTStyleSheet * self,
  164.         HTParagraphStyle * paraStyle));
  165. extern HTStyle * HTStyleMatching PARAMS((HTStyleSheet *self, HTStyle * style));
  166. /* extern HTStyle * HTStyleForRun PARAMS((HTStyleSheet *self, NXRun * run)); */
  167. extern HTStyleSheet * HTStyleSheetAddStyle PARAMS((HTStyleSheet * self,
  168.         HTStyle * style));
  169. extern HTStyleSheet * HTStyleSheetRemoveStyle PARAMS((HTStyleSheet * self,
  170.         HTStyle * style));
  171. #ifdef SUPPRESS
  172. extern HTStyleSheet * HTStyleSheetRead PARAMS((HTStyleSheet * self,
  173.                                                 HTStream * stream));
  174. extern HTStyleSheet * HTStyleSheetWrite PARAMS((HTStyleSheet * self,
  175.                                                 HTStream * stream));
  176. #endif
  177. #define CLEAR_POINTER ((void *)-1)      /* Pointer value means "clear me" */
  178. #endif /* HTStyle_H */
  179.  
  180.  
  181. /*
  182.  
  183.     */
  184.